<template>
	<view class="content">
		<view :class="show ? 'fade-in' : 'fade-out'">
			<manito-list :list="list"></manito-list>
			<w-load-more ref="wLoadMore"></w-load-more>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				playForm: {
					price_sort: '',
					price_name: '不限',
					sort: 1,
					page: 1,
					lng: '',
					lat: '',
					city: '请选择',
					sex: 0,
					sexName: '不限',
					game_id: ''
				},
				list: [],
				show: false
			};
		},
		onLoad(option) {
			uni.showLoading()
			this.playForm.game_id = option.id
			uni.setNavigationBarTitle({
				title: option.name
			})

			this.getList(1)
		},
		onReachBottom() {
			if (this.list.length < 20) return
			this.playForm.page++
			this.$refs['wLoadMore'].setLoading()
			this.getList()
		},
		methods: {
			async getList(loading) {
				try {
					let result = await this.$request({
						loading,
						method: 'post',
						url: '/api/play_index/index',
						data: {
							...this.playForm
						}
					})
					console.log(result)
					let data = result.data.data
					if (this.playForm.page == 1) {
						this.list = data
						this.show = true
						uni.hideLoading()
					} else {
						this.list = this.list.concat(data)
						this.$refs['wLoadMore'].setNomore()
						if (data.length == 0) {
							this.playForm.page--
						}
					}
				} catch (e) {
					console.log(e)
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx 30rpx 0 30rpx;
	}
</style>